using System.Collections;
using Holoville.HOTween;
using Holoville.HOTween.Core;
using UnityEngine;

public class ReloadingUI : MonoBehaviour
{
	public UILabel noAmmo;

	public UISprite[] reloadingSpritrs;

	private Coroutine disableCoroutine;

	public void ReloadAnimation(float duration)
	{
		base.gameObject.SetActive(true);
		if ((bool)noAmmo)
		{
			noAmmo.gameObject.SetActive(false);
		}
		UISprite[] array = reloadingSpritrs;
		UISprite sprite;
		for (int i = 0; i < array.Length; i++)
		{
			sprite = array[i];
			sprite.fillAmount = 0f;
			sprite.alpha = 0f;
			sprite.gameObject.SetActive(true);
			HOTween.Kill(sprite);
			HOTween.To(sprite, duration * 0.2f, new TweenParms().Prop("alpha", 1));
			HOTween.To(sprite, duration, new TweenParms().Prop("fillAmount", 1).OnComplete((TweenDelegate.TweenCallback)delegate
			{
				sprite.gameObject.SetActive(false);
			}));
		}
		if (disableCoroutine != null)
		{
			CoroutineRunner.Instance.StopCoroutine(disableCoroutine);
		}
		disableCoroutine = CoroutineRunner.Instance.StartCoroutine(DisableWithDelay(duration));
	}

	public void NoAmmo(float duration)
	{
		base.gameObject.SetActive(true);
		noAmmo.gameObject.SetActive(true);
		UISprite[] array = reloadingSpritrs;
		foreach (UISprite uISprite in array)
		{
			uISprite.fillAmount = 0f;
			uISprite.alpha = 0f;
			HOTween.Kill(uISprite);
		}
		noAmmo.alpha = 0f;
		HOTween.To(noAmmo, duration * 0.25f, new TweenParms().Prop("alpha", 1).OnComplete((TweenDelegate.TweenCallback)delegate
		{
			HOTween.To(noAmmo, duration * 0.25f, new TweenParms().Prop("alpha", 0.25).OnComplete((TweenDelegate.TweenCallback)delegate
			{
				HOTween.To(noAmmo, duration * 0.25f, new TweenParms().Prop("alpha", 1).OnComplete((TweenDelegate.TweenCallback)delegate
				{
					HOTween.To(noAmmo, duration * 0.25f, new TweenParms().Prop("alpha", 0));
				}));
			}));
		}));
		if (disableCoroutine != null)
		{
			CoroutineRunner.Instance.StopCoroutine(disableCoroutine);
		}
		disableCoroutine = CoroutineRunner.Instance.StartCoroutine(DisableWithDelay(duration));
	}

	private IEnumerator DisableWithDelay(float delay)
	{
		yield return new WaitForSeconds(delay);
		base.gameObject.SetActive(false);
	}
}
